package DepthFirstSearch;

import java.util.ArrayList;
import java.util.List;

public class _386_LexicographicalNumbers {
    List<Integer> res;
    int size;
    public List<Integer> lexicalOrder_0(int n) {
        this.res = new ArrayList<>();
        this.size = n;
        for (int i = 1; i <= 9; i++) {
            dfs(i);
        }
        return res;
    }

    public void dfs(int start) {
        if (start > size) {
            return;
        } else {
            res.add(start);
            int val = start * 10;
            for (int i = 0; i <= 9; i++) {
                int bias = val + i;
                dfs(bias);
            }
        }
    }

}
